<template>
    <div id="point-finish" :class="className" :style="{height:height,width:width}"></div>
</template>

<script>
    import echarts from 'echarts'
    export default {
        name: 'point-finish',
        props: {
            className: {
                type: String,
                default: 'point-finish-chart'
            },
            width: {
                type: String,
                default: '190px'
            },
            height: {
                type: String,
                default: '80px'
            },
            autoResize: {
                type: Boolean,
                default: true
            },
            pointData: {
                type: Object
            }
        },
        data () {
            return {
                chart: null,
                isResize:true,
            }
        },
        methods: {
            initChart() {
                this.chart = echarts.init(document.getElementById('point-finish'));
                this.setOptions()
            },
            setOptions({} = {}) {
                this.chart.setOption({
                    legend: {
                        orient: 'vertical',
                        data: ['已完成质控点', '未完成质控点'],
                        x: 'right',
                        y: 'center'
                    },
                    color: ['#42C0EC', '#7D7AFA'],
                    series: [
                        {
                            name: '访问来源',
                            type: 'pie',
                            radius: ['40%', '70%'],
                            center: [40, 40],
                            avoidLabelOverlap: false,
                            label: {
                                show: false,
                                position: 'center'
                            },
                            emphasis: {
                                label: {
                                    show: false,
                                    fontSize: '30',
                                    fontWeight: 'bold'
                                }
                            },
                            labelLine: {
                                show: false
                            },
                            data: [
                                {value: this.pointData.finishTotal, name: '已完成质控点'},
                                {value: this.pointData.noReachTotal , name: '未完成质控点'}
                            ]
                        }
                    ]
                });
                window.onresize = this.chart.resize;
            }
        },
        watch: {
            pointData: {
                handler(val) {
                    this.initChart();
                },
                deep: true
            }
        }
    }
</script>

<style scoped>

</style>
